package com.feng.online_xdclass.controller;


import com.feng.online_xdclass.model.entity.Video;
import com.feng.online_xdclass.model.entity.VideoBanner;
import com.feng.online_xdclass.service.VideoService;
import com.feng.online_xdclass.utils.JsonDate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("api/v1/pub/video")
public class VideoController {
    @Autowired
    private VideoService videoService;

    /**
     * 视频列表
     * @return
     */
    @RequestMapping("list")
    public JsonDate listVideo(){

        List<Video> videos = videoService.videoList();
        return JsonDate.bulidSuccess(videos);
    }

    /**
     * 轮播图列表
     * @return
     */
    @GetMapping("list_banner")
    public JsonDate indexBanner(){
     List<VideoBanner> bannerlist=videoService.listBanner();
     return JsonDate.bulidSuccess(bannerlist);
    }

    /**
     * 查询视频id，包含章集信息
     * @param videoId
     * @return
     */

    @GetMapping("find_detail_by_id")
    public JsonDate findDetailById(@RequestParam("video_id") int videoId){
      Video video =videoService.findDetailById(videoId);
      return JsonDate.bulidSuccess(video);
    }
}
